package krow.dev.gunpobus.view.adapter;

import java.util.List;

import krow.dev.gunpobus.model.TabItem;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;


public class TabPageAdapter extends FragmentPagerAdapter {

	private List<TabItem> mTabItemList;
	
	public TabPageAdapter(FragmentManager fragmentManager, List<TabItem> tabItemList) {
		super(fragmentManager);
		
		mTabItemList = tabItemList;
	}
	
	@Override
	public CharSequence getPageTitle(int position) {
		
		return mTabItemList.get(position).getName();
	}

	@Override
	public int getCount() {
		
		return mTabItemList.size();
	}

	@Override
	public Fragment getItem(int position) {
		
		TabItem tabItem = mTabItemList.get(position);
		
		Fragment fragment = null;
		try {
			fragment = tabItem.getFragment().newInstance();
		} catch (Exception e) {

		}
		//Bundle arguments = new Bundle();
		//arguments.putString(Invoke.KEY_CATEGORY, tabItem.getCategory());
				
		return fragment;
	}

}
